package com.lsc.www.day04;

public class BubbleSort {

    //考试成绩 99 98 70 60 30 50 100 10 0
    public static void main(String[] args) {
        int[] arr = new int[]{3,1,6,9,90,88,56,4};
        for (int i = 0 ;  i<arr.length -1 ; i++){
            System.out.println("第"+(i+1)+"轮");
//            System.out.println(arr[i]);
            for (int j = 0 ; j < arr.length - 1 - i; j++){
                System.out.println(arr[j]+ "和" +arr[j+1]+"比较");
                if(arr[j]>arr[j+1]){//arr[j] = 3 arr[j+1] = 1
                    int temp = arr[j]; // temp = 3 =  arr[j] = 3
                    arr[j]=arr[j+1];// arr[j] = 1 = arr[j+1] = 1
                    arr[j+1] = temp; //  arr[j] = 3 = tmep = 3
                }
            }
        }
    }


}
